<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>service-abc</artifactId>
        <groupId>abc-dev</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>abc-api</artifactId>
    <properties>
        <java.version>17</java.version>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <!--域名 命名空间-->
        <docker.registry>registry.cn-shenzhen.aliyuncs.com</docker.registry>
        <docker.base.java8.image>anapsix/alpine-java:8_server-jre_unlimited</docker.base.java8.image>
        <docker.base.java17.image>openjdk:17-oracle</docker.base.java17.image>
        <docker.registry.namespace>namespace</docker.registry.namespace>
        <docker.username>username</docker.username>
        <docker.password>password</docker.password>
    </properties>
    <dependencies>
        <dependency>
            <groupId>abc-dev</groupId>
            <artifactId>abc-validation</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>abc-dev</groupId>
            <artifactId>abc-business</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>abc-dev</groupId>
            <artifactId>abc-core</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <!--轻量级熔断框架-->
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-circuitbreaker-resilience4j</artifactId>
        </dependency>
        <dependency>
            <groupId>abc-dev</groupId>
            <artifactId>abc-datasource</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <!-- mybatis-plus -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.2</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-core</artifactId>
            <version>3.5.2</version>
        </dependency>

        <!-- SpringCloud Alibaba Sentinel -->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
            <version>2022.0.0.0-RC1</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>abc-api</finalName>
        <defaultGoal>compile</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <source>17</source>
                    <target>17</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.4.3</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>build-image</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <from>
                        <image>${java17}</image>
                    </from>
                    <to>
                        <image>${dockerRegistry}/${dockeRegistryNamespace}/${artifactId}:${projectVersion}</image>
                        <auth>
                            <username>${dockerUsername}</username>
                            <password>${dockerPassword}</password>
                        </auth>
                    </to>
                    <allowInsecureRegistries>true</allowInsecureRegistries>
                    <container>
                        <entrypoint>
                            <arg>/bin/sh</arg>
                            <arg>-c</arg>
                            <arg>
                                java $JAVA_OPTS -noverify -XX:+AlwaysPreTouch -cp /app/resources/:/app/classes/:/app/libs/* "abc.${packageName}.ServiceAbcApplication" "$@"
                            </arg>
                        </entrypoint>
                        <jvmFlags>
                            <jvmFlag>-Xms512m</jvmFlag>
                            <jvmFlag>-Xmx1g</jvmFlag>
                            <jvmFlag>-Duser.timezone=Asia/Shanghai</jvmFlag>
                        </jvmFlags>
                        <ports>
                            <port>8088</port>
                        </ports>
                        <environment>
                            <SPRING_OUTPUT_ANSI_ENABLED>ALWAYS</SPRING_OUTPUT_ANSI_ENABLED>
                            <SERVER_SLEEP>0</SERVER_SLEEP>
                        </environment>
                    </container>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
                <plugin>
                    <groupId>com.google.cloud.tools</groupId>
                    <artifactId>jib-maven-plugin</artifactId>
                    <version>1.8.0</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <resources>
            <resource>
                <!-- xml放在java目录下-->
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <!--指定资源的位置（xml放在resources下，可以不用指定）-->
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/spring.factories</include>
                    <include>**/*.yml</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
</project>
